﻿namespace SW.Lite.Infrastructure.Configuration
{
    public class Connection
    {
        /// <summary>
        ///     连接类型
        /// </summary>
        public ConnectionType Type { get; set; }

        /// <summary>
        ///     地址
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        ///     数据库
        /// </summary>
        public string Database { get; set; }

        /// <summary>
        ///     用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        ///     密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        ///     连接字符串
        /// </summary>
        public string ConnectionString
        {
            get
            {
                return "Data Source=" + Address + ";Database=" + Database + ";User ID=" + UserName + ";Password=" + Password;
            }
        }

        /// <summary>
        ///     DAL层的命名空间
        /// </summary>
        public string DalNamespace
        {
            get { return "SW.Lite.DAL." + Type; }
        }
    }

    public enum ConnectionType
    {
        /// <summary>
        ///     Ms SQL
        /// </summary>
        MsSql = 0,

        /// <summary>
        ///     MySQL
        /// </summary>
        MySql = 1
    }
}